<?php
/*
 * Test url params: ?max_message_count=20&from_datetime=Fri%2C+30+May+2007+19%3A40%3A13+%2B0600
 */

require_once("../etc/config.php");
$instance_conf = $self;

require_once("config.php");
require_once("../etc/conf.d/db.php");

require_once("Process.php");
require_once("../lib/Logger/Logger.php");
require_once("../lib/RL/CyrDate.php");
require_once("../lib/RL/RequestRouter.php");
require_once("../lib/RL/RequestRouter/Regexp.php");
require_once("../lib/RL/URLGenerator.php");

// инициализация правил генерации урла
$router = new RL_RequestRouter();

$self = $router;
$pattern = 'RL_RequestRouter_Regexp';

$self->defaults['base_url'] = $base_url;
require_once("../etc/conf.d/url.php");
require_once("../etc/url/item.php");
require_once("../etc/url/comment.php");

$self->addRules($item);
$self->addRules($comment);

require_once("EventHandler.php");
require_once("DeleteEventHandler.php");
require_once("DocumentEventHandler.php");
require_once("ImageEventHandler.php");
require_once("LinkEventHandler.php");
require_once("FileEventHandler.php");
require_once("CommentEventHandler.php");
require_once("DbStorage.php");
require_once("smallDBAL.php");
require_once("UrlGenThing.php");
require_once("UrlGenItem.php");
require_once("UrlGenComment.php");

$db = new smallDBAL($db_config);
$url_gen = new UrlGenThing($router, $db);
$em = new Process($url_gen);
$em->dbs = new DbStorage($db);
$em->sm_db = $db;
header('Content-Type: text/xml');
$em->setSiteInfo(array(
	"email"=>$instance_conf['admin_email'],
	"uid"=>$instance_conf['project_key'],
	"base_url"=>$base_url,
	"site_name"=>$instance_conf['project_title']
	));

if (!isset($_GET['from_datetime']) || !isset($_GET['max_message_count'])) die("Не переданы параметры запроса");

$from_dt = strtotime($_GET['from_datetime']);
$max_msg_cnt = $_GET['max_message_count'];

$em->getData($from_dt, "myopenid.com", $max_msg_cnt);
echo $em->getXML();
//echo ( strlen($xml) );

?>
